<?php
	session_start();
	mysql_connect("localhost", "sapmenet_admin", "a1s2d3f4g5h6j7") or die ("Problem with datebase");
	mysql_select_db("sapmenet_users");
?>
	<div id = "jorosPageResult">
	</div>
	<script type = 'text/javascript' src = 'jquery-1.7.js'></script>
	<script>
	var userNames = new Array();
	var userIDs = new Array();
	$.post('onlineUsers.php', function(data)
	{
		if(data != "")
		{
			var returnedString = data;
			var allThings = new Array();
			allThings = returnedString.split(',');
			var dataLenght = allThings.length;
			var one = 0;
			var two = 0;
			for(i = 0; i< dataLenght; i++)
			{
				if(i%2 == 0)
				{
					userIDs[two] = allThings[i];
					two++;
				}
				else
				{
					userNames[one] = allThings[i];
					one++;
				}
			}
			for(i = 0; i<two; i++)
			{
				$('#jorosPageResult').append("<div class = 'singleOnlineUserDiv' id = "+userIDs[i]+" onclick = 'kuche("+i+")'>"+userNames[i]+"</div><br>");
			}
		}
		else
		{
			$('#jorosPageResult').html("<div id = 'noOne'>No online friends</div>");
		}
	});
	function kuche(curName)
	{
		$.post("showMessages.php", {ot : userIDs[curName]}, function(data)
		{
			$(".messagesField").html(data);
			$(".messagesField").scrollTop(9000);
		});
		$("#interlocutorHeaderNameText").html(userNames[curName]);
		$('.chatWindowHeader').attr('id', userIDs[curName]);
		$.post('showProfilePicture.php', {picture:userIDs[curName]}, function(data)
		{
			$('.chatPfffPicture').html(data);
		});
		$(".singleChatDialog").show("explode");
		$(".messagesField").scrollTop(9000);
	}
	</script>




















































































